import { createStore } from 'vuex'
import createPersistedState from "vuex-persistedstate"
export default createStore({
    state: {
        isGetterRouter: false,
        isCollapsed: false, //左侧菜单是否水平折叠,
        userInfo: {}
    },
    getters: {},
    mutations: {
        changeGetterRouter(state, value) {
            state.isGetterRouter = value
        },
        // 控制侧边栏的展开
        changeCollapsed(state) {
            state.isCollapsed = !state.isCollapsed
        },
        changeUserInfo(state, value) {
            state.userInfo = {
                ...state.userInfo,
                ...value
            }
        },
        clearUserInfo(state, value) {
            state.userInfo = {}
        }
    },
    actions: {},
    modules: {},
    plugins: [createPersistedState({
        paths: ["isCollapsed", "userInfo"] //控制是否持久化 ,如果不写如：plugins: [createPersistedState()] 就全部持久化，现在isGetterRouter不需要持久化
    })]
})